<template>
  <div id="app">
    <!-- <mainNav/> -->
    <transition :name="transtionSlide"
      :enter-active-class="'slide-active'"
      :leave-active-class="'slide-active'"
      mode="out-in">
      <keep-alive include="sjlists">
        <!-- <navigation> -->
        <router-view></router-view>
        <!-- </navigation> -->
      </keep-alive>
    </transition>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
// import mainNav from "@/components/mainNav.vue";
export default {
  name: "App",
  data() {
    return {
      transtionSlide: "slide-left",
      wxInfoa: {
        wxAppId: "",
        wxTimestamp: "",
        wxNonceStr: "",
        wxSignature: ""
      }
    };
  },
  computed: {
    ...mapState(["isLogin", "logPhoneNum"])
  },
  methods: {
    ...mapActions(["loginAction", "setPhoneNum"])
  },
  created() {
    this.$navigation.on("forward", () => {
      this.transtionSlide = "slide-left";
    });
    this.$navigation.on("back", () => {
      this.transtionSlide = "slide-right";
    });
    document.body.removeChild(document.getElementById("loading"));
    this.$axios
      .get(
        this.$API.api +
          "/report/?i=3&c=entry&m=nifty&do=mobile&d=WGSAppointment&f=getLoginStatus"
      )
      .then(res => {
        console.log(res);
        if (res.status === 200) {
          let state = res.data.isLogin === true ? 1 : 0;
          // console.log(state);
          this.loginAction(state);
          if (res.data.isLogin === true) {
            this.setPhoneNum(res.data.phoneNum);
          }
        }
      })
      .catch(err => {
        console.log(err);
      });
  },
  mounted() {}
};
</script>

<style lang="scss">
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  overflow: hidden;
}
.slide-active {
  transition: 0.3s cubic-bezier(0.55, 0, 0.1, 1);
  transition-property: opacity, transform;
}
.slide-left-enter,
.slide-right-leave-to {
  opacity: 0;
  transform: translate3d(30%, 0, 0);
}
.slide-left-leave-to,
.slide-right-enter {
  opacity: 0;
  transform: translate3d(-30%, 0, 0);
}
</style>
